<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'defaultRoute' => 'index',
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'modules' => [],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
        ],
        'user' => [
            'identityClass' => 'backend\models\AdminUser',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
            'as afterLogin' => \backend\behaviors\AdminAuthBehavior::class
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 1 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning', 'info'],
                    'categories' => [
                        'yii\db\*',
                        //'backend\models\*',
                        //'yii\web\HttpException:*',
                    ],
                    'logVars'=>[],
                    'logFile' => '@runtime/../runtime/logs/yii_sql_' . date('y_m_d') . '.log',
                ]
            ],


        ],
        'services' => [
            'class' => 'backend\services\Services',
        ],
        'menuCache'=>[
            'class'=>'yii\caching\FileCache'
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
        'elasticsearch' => [
            'class' => 'yii\elasticsearch\Connection',
            'nodes' => [
                ['http_address' => '172.18.42.57:9201'],
                // configure more hosts if you have a cluster
            ],
            'connectionTimeout' => 3, //连接超时
            // set autodetectCluster to false if you don't want to auto detect nodes
            // 'autodetectCluster' => false,
            //'dslVersion' => 7, // default is 5
        ],

    ],
    'params' => $params,
];
